﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace rndbuddy
{
    public partial class validate_by_whatsapp : Form
    {
        string mail_from_apply;

        public validate_by_whatsapp(string mail)
        {
            InitializeComponent();
            mail_from_apply = mail;
        }

        private void ck1_CheckedChanged(object sender, EventArgs e)
        {
            switch (ck1.Checked)
            {
                case true: ck2.Enabled = true; break;
                case false: ck2.Enabled = false; break;
            }
        }

        private void ck2_CheckedChanged(object sender, EventArgs e)
        {
            switch (ck2.Checked)
            {
                case true: inp_mobile.Enabled = true; break;
                case false: inp_mobile.Enabled = false; break;
            }
        }

        private void inp_mobile_TextChanged(object sender, EventArgs e)
        {
            btn_whatsapp.Enabled = true;
        }

        private void btn_whatsapp_Click(object sender, EventArgs e)
        {
            string[] result = server_pipe.apply_by_whatsapp(mail_from_apply, inp_mobile.Text.Trim());
            if (result[0] != "true")
            {
                MessageBox.Show(result[1], "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("OK, a message was sent to " + inp_mobile.Text.Trim());
                this.Dispose();
            }
        }
    }
}
